<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 1、求1 + 2！ + 3！ + 4！....+20!的值
    console.log("1！+...+20！")
    var n = 1;
    var sum = 0;
    for(var i = 1; i<=20; i++){
        n *= i;
        sum = sum + n;
    }
    console.log(sum)
    console.log("---------")
    // 2、求叠数之和(1-9)
    //  n = 1   2
    //  n = 2   2+ 2*10 = 22
    //  n = 3   2+ 22*10 = 222
    //  n = 4   2+ 222*10 = 2222
    console.log("求叠数之和")
    var n = 3;
    var a = 3;
    var sum = 0;
    var j = a;
    for(var i = 1 ; i <= n ;i++){
        sum += a;
        a = a*10 + j;
    }
    console.log(sum );
    console.log("---------")
    // 3、输入两个数求两个数的最大公约数
    console.log("输入两个数求两个数的最大公约数")
    var min = 12;
    var max = 18;
    var tem = 0;
    if(min > max){
        tem = min;
        min = max;
        max = tem;
    }
    if( max % min === 0){
        console.log(min)
    }else{
        var ls = min;
        for(var i = min ; true ; min--){
            if(max % min === 0 && ls % min === 0){
                console.log(min)
                break
            }
        }

    }
    
    console.log("---------")
    // 4、输入两个数，求两个数的最小公倍数
    console.log("输入两个数，求两个数的最小公倍数")
    var min = 12;
    var max = 18;
    var tem = 0;
    if(min > max){
        tem = min;
        min = max;
        max = tem;
    }
    for(var i = max ; i <= max*min ; i++){
        if( i % max === 0 && i % min === 0 ){
            console.log(i)
            break
        }
    }
    console.log("---------")
    

    // 5、回文数
    console.log("回文数")
    for(var i=10000;i<=99999;i++){
        var w = parseInt(i/10000);
        var q = parseInt(i/1000)%10;
        var b = parseInt(i/100)%10;
        var s = parseInt(i/10)%10;
        var g = i%10;
        if(w === g && q === s && q === w+1 && b === q+1){
            console.log(i)
        }
    }
    console.log("---------")

</script>
</html>